package account.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Random;

import javax.swing.JTextField;

import dao.account.DataLayerAccount;
import account.model.Account;
import account.view.MailRecoveryView;
import tools.mail.Mail;

public class MailController implements ActionListener {

	//TODO Kishan

	//	private String hold;
	Mail mail=new Mail();
	Account acc=new Account();
	DataLayerAccount da=new DataLayerAccount();
	MailRecoveryView mrv;

	@Override
	public void actionPerformed(ActionEvent e) {
		if("zoeken".equals(e.getActionCommand())){

			zoekaccount();
		}

	}

	public void zoekaccount(){

		String hold= MailRecoveryView.getInstance().getTxtMail();

		/*
		try {
//			acc=da.Checkformail(hold);

		} catch (SQLException e) {
			e.printStackTrace();
		}*/
		try {
			acc=da.checkbirth(1996);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		System.out.println(acc);
		/*
			String pass=generatepassword();
			acc.setWachtwoord(pass);	
			da.updateStudent(acc);
			mail.recoverwachtwoord(acc);	
		 */

	}




	public String generatepassword(){
		char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
		StringBuilder sb = new StringBuilder();
		Random random = new Random();
		for (int i = 0; i < 8; i++) {
			char c = chars[random.nextInt(chars.length)];
			sb.append(c);
		}
		String output = sb.toString();
		return output;
	}
}
